﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace QuickMAP.UI
{
    public partial class frmLoading : Form
    {
        BackgroundWorker worker = new BackgroundWorker();
        public frmLoading()
        {
            InitializeComponent();
            worker.WorkerReportsProgress = true;
            worker.WorkerSupportsCancellation = true;
            worker.DoWork += new DoWorkEventHandler(worker_DoWork);
            worker.ProgressChanged += new ProgressChangedEventHandler(worker_ProgressChanged);
        }

        void worker_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            progressBar1.Value = e.ProgressPercentage;
        }

        void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            worker.ReportProgress(100);
            System.Threading.Thread.Sleep(100);
        }

        private void frmLoading_FormClosing(object sender, FormClosingEventArgs e)
        {
            worker.CancelAsync();
            progressBar1.Value = 100;
            System.Threading.Thread.Sleep(100);
        }

        private void frmLoading_Load(object sender, EventArgs e)
        {
            worker.RunWorkerAsync();
        }
    }
}
